package com.cr.crandroid.utils;

import java.util.Map;

public class OConvertUtils {

    public static String getString(String s) {
        return (s.replace("\"", ""));
    }

    //添加参数
    public static String getBodyParams(String url, Map<String, String> bodyParams) {
        //1.添加请求参数
        //遍历map中所有参数到builder
        if (bodyParams != null && bodyParams.size() > 0) {
            StringBuilder stringBuilder = new StringBuilder("?");
            for (String key : bodyParams.keySet()) {
                if (bodyParams.get(key) != null) {//如果参数不是null，就拼接起来
                    stringBuilder.append("&");
                    stringBuilder.append(key);
                    stringBuilder.append("=");
                    stringBuilder.append(bodyParams.get(key));
                }
            }

            return url + stringBuilder.toString();
        } else {
            return "";
        }
    }

}
